# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=idris2-stage0
pkgver=0.7.0
pkgrel=1
pkgdesc="Idris 2 version used to bootstrap the Idris 2 compiler"
url="https://www.idris-lang.org"
# idris2 requires chez-scheme's foreign function interface.
# This doesn't seem to be supported on portable bytecode targets (ppc64le, s390x).
arch="all !ppc64le !s390x"
license="BSD-3-Clause"
depends="chez-scheme gmp-dev"
makedepends="bash"
source="https://github.com/idris-lang/Idris2/archive/v$pkgver/idris2-$pkgver.tar.gz
	fix-expected-cat-err.patch"
builddir="$srcdir/Idris2-$pkgver"

# Provide idris2-bootstrap for testing/idris2.
# See the comment in testing/idris2 for more information.
provides="idris2-bootstrap=$pkgver"
provider_priority=1 # lowest

# Only run tests on x86_64, upstream doesn't seem to support
# and test the test suite on any other architecture.
#
# See: https://github.com/idris-lang/Idris2/issues/1617
case "$CARCH" in
x86_64) ;;
*) options="!check" ;;
esac

build() {
	# Bootstrap Idris 2 compiler from scheme sources.
	make -j1 bootstrap PREFIX=/usr SCHEME=chez
}

check() {
	unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LDLIBS
	make -j1 bootstrap-test
}

package() {
	make DESTDIR="$pkgdir" PREFIX="/usr" install
}

sha512sums="
3c645807d71ecf62bc66b674438ebf80ec6e7e4bbf473d86ec06bc7b59f8187618e0d56535380079837e15caebef02deba9beb3eb3c77da787befac88d7a6d2b  idris2-0.7.0.tar.gz
6438bf25c0e9dede104a3b73dfe3a1bd4f1615d6c37589058b9192f5813ab6e41833319a1a2f9aaa6e2559d198697f3d4a27fc6908fe7ae193af03085af268b5  fix-expected-cat-err.patch
"
